{% extends "OspUserBundle::layout.html.twig" %}

{% block OspUser_body %}
	<h3>Liste des utilisateurs</h3>


	<ul class="nav nav-pills nav-stacked">
		<table class="table table-striped">
			<thead>
				<tr>
					<th>ID</th>
					<th>Rôle</th>
					<th>Nom</th>
					<th>Prénom</th>
					<th>Adresse</th>
					<th>Code Postal</th>
					<th>Ville</th>
					<th>Email</th>
					<th>Téléphone</th>
				</tr>
			</thead>
			
			<tbody>
				{% for user in users %}
				<tr>
					<td>{{user.id}}</td>
					<td>{{user.getRolesString()}}</td>
					<td>{{user.nom}}</td>
					<td>{{user.prenom}}</td>
					<td>{{user.adresse}}</td>
					<td>{{user.codePostal}}</td>
					<td>{{user.ville}}</td>
					<td>{{user.email}}</td>
					<td>{{user.telephone}}</td>
					<td>
						<a href="{{ path('osp_user_update', {'id' : user.id}) }}">
							<img src="{{ asset('img/update.png') }}" alt="Modifier" height="27" width="27" />
						</a>
					</td>
					<td>

						<a href="{{ path('osp_user_delete', {'id' : user.id}) }}" onclick="return confirm('Êtes-vous sûr ? Toutes les données associées à cet utilisateur seront supprimées !')">
							<img src="{{ asset('img/delete.png') }}" alt="Supprimer" height="27" width="27" />
						</a>
					</td>
				</tr>	
				{% endfor %}
			</tbody>
		</table>

		{%if error%}
		{{error}}
		{%endif%}

		<br/>
		<br/>

<div class="well form-inline">
	<form method="post" {{ form_enctype(form) }}>
		
		<legend>Créer un utilisateur</legend>
		<table class="table table-striped">
			<thead>
				<tr>
					<th>Login</th>
					<th>Mot de passe</th>
					<th>Rôle</th>
					<th>Nom</th>
					<th>Prénom</th>
				</tr>
			</thead>
			
			<tbody>
				<tr>
					<td>{{ form_widget(form.username, { 'attr': {'class': 'input-small'} }) }}</td>
					<td>{{ form_widget(form.password, { 'attr': {'class': 'input-small'} }) }}</td>
					<td>{{ form_widget(form.roles, { 'attr': {'class': 'input-small'} }) }}</td>
					<td>{{ form_widget(form.nom, { 'attr': {'class': 'input-small'} }) }}</td>
					<td>{{ form_widget(form.prenom, { 'attr': {'class': 'input-small'} }) }}</td>
				</tr>	
			</tbody>

			<thead>
				<tr>
					<th>Adresse</th>
					<th>Code Postal</th>
					<th>Ville</th>
					<th>Email</th>
					<th>Téléphone</th>
				</tr>
			</thead>

			<tbody>
				<tr>
					<td>{{ form_widget(form.adresse, { 'attr': {'class': 'input-small'} }) }}</td>
					<td>{{ form_widget(form.codePostal, { 'attr': {'class': 'input-small'} }) }}</td>
					<td>{{ form_widget(form.ville, { 'attr': {'class': 'input-small'} }) }}</td>
					<td>{{ form_widget(form.email, { 'attr': {'class': 'input-small'} }) }}</td>
					<td>{{ form_widget(form.telephone, { 'attr': {'class': 'input-small'} }) }}</td>
				</tr>	
			</tbody>
		</table>
		<input type="submit" class="btn btn-primary" value="Créer Utilisateur" style="margin-left:80%" />
		{{ form_rest(form) }}
	</form>
</div>

{% endblock %}